<?php
// 页面 url
$pageURL = "./PoblingBuy.php";
// 获取 cookie 如果没有 则设置 生成必要信息
$key0 = "";
$key1 = "";
if (!isset($_COOKIE['key0'])){
  $key0 = "v1.0.0";
  setcookie("key0", "v1.0.0", time()+63072000); // 版本号 v1.0.0
}else{
  $key0 = $_COOKIE['key0'];
}
if (!isset($_COOKIE['key1'])){
  $key1 = md5(uniqid().":".mt_rand(1,1000000));
  setcookie("key1", $key1, time()+63072000); // 用户账号 随机生成
}else{
  $key1 = $_COOKIE['key1'];
}

// 取得 ip
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknow";
// 判断设备
$she_bei = "";
$liu_lan_qi = $_SERVER ['HTTP_USER_AGENT'];
function is_mobile() {
  $user_agent = $_SERVER ['HTTP_USER_AGENT'];
  $mobile_browser = Array (
      "mqqbrowser", // 手机QQ浏览器
      "opera mobi", // 手机opera
      "juc",
      "iuc", // uc浏览器
      "fennec",
      "ios",
      "applewebKit/420",
      "applewebkit/525",
      "applewebkit/532",
      "ipad",
      "iphone",
      "ipaq",
      "ipod",
      "iemobile",
      "windows ce", // windows phone
      "240×320",
      "480×640",
      "acer",
      "android",
      "anywhereyougo.com",
      "asus",
      "audio",
      "blackberry",
      "blazer",
      "coolpad",
      "dopod",
      "etouch",
      "hitachi",
      "htc",
      "huawei",
      "jbrowser",
      "lenovo",
      "lg",
      "lg-",
      "lge-",
      "lge",
      "mobi",
      "moto",
      "nokia",
      "phone",
      "samsung",
      "sony",
      "symbian",
      "tablet",
      "tianyu",
      "wap",
      "xda",
      "xde",
      "zte"
  );
  $is_mobile = false;
  foreach ( $mobile_browser as $device ) {
    if (stristr ( $user_agent, $device )) {
      $is_mobile = true;
      break;
    }
  }
  return $is_mobile;
}
if(is_mobile()){
  $she_bei = "mobile";
}else{
  $she_bei = "pc";
}


  // 向数据库插入
  // 开DB连接
  $dbConnection = new PDO('mysql:dbname=firstpanda;host=127.0.0.1;charset=utf8', 'firstpanda', 'Apanda13689');
//  $dbConnection = new PDO('mysql:dbname=dhshop;host=127.0.0.1;charset=utf8', 'root', 'panda123');
  $dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  //$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');
  $stmt = $dbConnection->prepare('INSERT INTO fang_wen_ji_lu_biao (cookie_ban_ben,yong_hu_zhang_hao,yong_hu_mi_ma,fang_wen_url,fang_wen_shi_jian,ip,she_bei,liu_lan_qi) VALUES (:cookie_ban_ben,:yong_hu_zhang_hao,:yong_hu_mi_ma,:fang_wen_url,now(),:ip,:she_bei,:liu_lan_qi)');
  $stmt->execute(array(':cookie_ban_ben' => $key0,':yong_hu_zhang_hao' => $key1,':yong_hu_mi_ma' => $key1,':fang_wen_url' => $pageURL,':ip' => $ip,':she_bei' => $she_bei, ':liu_lan_qi' => $liu_lan_qi));
  // 关DB连接
  $dbConnection = null;


 ?>

 <!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>3D聲波潔面儀</title>
		<meta name="keywords" content="3D聲波潔面儀" />
		<meta name="description" content="3D聲波潔面儀" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />

		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->

		<link rel="stylesheet" href="assets/css/h_showcss.css" />
    <!-- Facebook Pixel Code -->
    <script>
    !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};
    if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
    n.queue=[];t=b.createElement(e);t.async=!0;
    t.src=v;s=b.getElementsByTagName(e)[0];
    s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');
    fbq('init', '1274057949323037');
    fbq('track', 'PageView');
    </script>
    <noscript>
    <img height="1" width="1" src="https://www.facebook.com/tr?id=1274057949323037&ev=PageView&noscript=1"/>
    </noscript>
    <!-- End Facebook Pixel Code -->
	</head>

	<body style="background-color: #F1F1F2;">
		<div class="navbar navbar-default" id="navbar" style="text-align:center;background-color:#DE2327;line-height: 45px;color:#fff;">
			<script type="text/javascript">
				try{ace.settings.check('navbar' , 'fixed')}catch(e){}
			</script>
      <!-- 标题 -->
			<a href="Pobling.php" class="col-xs-4" style="color:#fff;text-align: left">返回上一頁</a>
        <span class="col-xs-6">產品信息</span>
		</div>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>
			<div class="main-container-inner">
				<div class="main-content">
          <!-- 上方图片的外框 -->
          <div class="col-xs-12" id="picBefore" style="padding-left:0px;padding-right:0px;padding-bottom:10px;background-color:#F1F1F2;">
          </div>
<form id="h_form" name="hn_form" action="php/BuyErJixs.php" method="post" onsubmit="return postcheck()">
					<!-- 產品 -->
					<div class="row" style="margin-right:0px;">
						<div class="col-xs-12" style="padding-right:0px;">
							<div class="col-xs-12">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>產品</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<!-- 行1 -->
									<div class="col-xs-12" style="padding-right:0px;padding-left:0px;font-size: 14px;color:#DE2327;">
										<input type="radio" name="hn_product" value="XS00001" checked="checked" />
										<b>3D聲波潔面儀</b>
									</div>

								</div>
								</div>
							</div>
						</div>
					</div>

          <!-- 类型 -->
          <div class="row" style="margin-right:0px;">
						<div class="col-xs-12" style="padding-right:0px;">
							<div class="col-xs-12">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>類型</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<!-- 行1 -->
									<div class="col-xs-12" style="padding-right:0px;padding-left:0px;margin-top:10px;">
										<div class="col-xs-6" style="padding-right:0px;padding-left:0px;font-size: 14px;color:#DE2327;">
											<img class="col-xs-12" src="img/jmy/type.jpg" >
											<div class="col-xs-12"><input type="radio" name="hn_type" value="1" checked="checked"><span><b> 145*65mm聲波震動型</b></span></div>
										</div>
									</div>

								</div>
							</div>
						</div>
          </div>

					<!-- 其他 -->
					<div class="row" style="margin-bottom:90px;margin-right:0px;">
						<div class="col-xs-12">
							<!-- 数量  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>數量</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<button id="hi_minus" type="button" style="height:29px;width:29px;border:1px solid #dadada;background-color:#fff;">-</button>
									<input id="hi_count" name="hn_count" value="1" style="height:29px;width:58px;" />
									<button id="hi_plus" type="button" style="height:29px;width:29px;border:1px solid #dadada;background-color:#fff;">+</button>
								</div>
							</div>
							<!-- 姓名  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>姓名</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input name="hn_name" class="col-xs-11" style="height:29px;"/>
								</div>
							</div>
							<!-- 手机  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>手機</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input name="hn_phone" class="col-xs-11" style="height:29px;"/>
								</div>
							</div>
							<!-- E-mail -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="font-size: 14px;color:#333"><b>E-mail</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input placeholder="填寫常用的郵箱(可選)" name="hn_email" class="col-xs-11" style="height:29px;"/>
								</div>
							</div>
							<!--  详细  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>詳細</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input placeholder="重要 某市+某區+街道門牌信息" name="hn_xx" class="col-xs-11" style="height:29px;"/>
								</div>
							</div>
							<!--  金额  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>金額</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input id="h_setprice" class="col-xs-3" value="1688" style="height:29px;" readonly="true"/><span style="font-size: 14px;color:#333;margin-left:5px;"><b>圓</b></span>
								</div>
							</div>
							<!--  付款方式  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="color:#DE2327">*</span>
									<span style="font-size: 14px;color:#333"><b>付款</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<input type="radio" name="h_payType" checked="checked" /><image src="img/hdfk.gif">
								</div>
							</div>
							<!--  温馨提示  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<span style="color:red;">溫馨提示：支持貨到付款+免郵費+七天無理由退換貨！收到貨有任何疑問請聯繫我們在線客服!
									同時請附上您的姓名及聯繫方式及訂單編號在郵件當中，以便我們能快速的給您及時處理，祝您購物愉快！！！</span>
								</div>
							</div>
							<!--  留言  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-2" style="padding-right:0px;padding-left:0px;">
									<span style="font-size: 14px;color:#333"><b>留言</b></span>
								</div>
								<div class="col-xs-10" style="padding-right:0px;padding-left:0px;">
									<textarea name="hn_ly" class="col-xs-11" placeholder="如備用聯繫電話" style="height:29px;"></textarea>
								</div>
							</div>
							<!--  按钮  -->
							<div class="col-xs-12" style="margin-top:10px;">
								<div class="col-xs-3"></div>
								<button class="col-xs-6" type="submit" style="border-radius:8px;background-color:#00CC33;border:1px solid #dadada;height:40px;text-align:center;line-height: 40px;color:#fff">
									<b>提交訂單</b>
								</button>
								<div class="col-xs-3"></div>
							</div>
						</div>
					</div>

</form>

				</div><!-- /.main-content -->
			</div><!-- /.main-container-inner -->
		</div><!-- /.main-container -->

		<!-- basic scripts -->



		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>

    		<script src="/js/postcheck.js" type="text/javascript"></script>
		<!-- inline scripts related to this page -->

		<script type="text/javascript">
			jQuery(function($) {
        // 获取屏幕宽
      //  alert(screen.width);
        if(screen.width > 374){
          $("#oldPrice").show();
        }
        // 获取屏幕长
      //  alert(screen.height);

				$('#loading-btn').on(ace.click_event, function () {
					var btn = $(this);
					btn.button('loading')
					setTimeout(function () {
						btn.button('reset')
					}, 2000)
				});

				$('#id-button-borders').attr('checked' , 'checked').on('click', function(){
						$('#default-buttons .btn').toggleClass('no-border');
				});
/*
        function hidepop(){

          $("#POP800_LEAVEWORD_DIV").hide();
          $("#POP800_INIT_DIV").hide();
          $("#POP800_LEAVEWORD_FROM").hide();
          $("#LEAVEWORD_FRAME").hide();
        }
        setInterval(hidepop,1000);
*/
			})

      // 點擊+ - 按鈕數字對應變動
			// 加
			$("#hi_plus").click(function(){
				// 加一个正则校验，校验是否输入的是数字，如果不是数字的话置1
				// 获取
				var h_count = parseInt($("#hi_count").val());
				if(isNaN(h_count)){
					h_count = 1;
				}
				// 加1
				h_count = h_count + 1;
				// 放回
				$("#hi_count").val(h_count);
        var basePrice = h_count * 1688;
        $('input[name=username]').removeAttr("readonly");
        $("#h_setprice").val(basePrice);
        $('input[name=username]').attr("readonly");
			});
			// 减
			$("#hi_minus").click(function(){
				// 获取
				var h_count = parseInt($("#hi_count").val());
				// 判断
				if(isNaN(h_count)){
					h_count = 1;
				}
				// 减1
				h_count = h_count - 1;
				// 放回
				if(h_count < 1){
					// 如小于0 就放0
					$("#hi_count").val("1");
          var basePrice = 1688;
          $('input[name=username]').removeAttr("readonly");
          $("#h_setprice").val(basePrice);
          $('input[name=username]').attr("readonly");
				}else{
					$("#hi_count").val(h_count);
          var basePrice = h_count * 1688;
          $('input[name=username]').removeAttr("readonly");
          $("#h_setprice").val(basePrice);
          $('input[name=username]').attr("readonly");
				}
			});
		</script>
  <script language="javascript" src="http://api1.pop800.com/800.js?n=250757&s=01&p=r&l=ct"></script><div style="display:none;"><a href="http://www.pop800.com">在線客服</a></div>
</body>
</html>
